﻿<?php
$con = mysql_connect("localhost","cubeMass_f","cubeSelectNow");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("cubeMass", $con);
session_start();
	if($_SESSION[user_id]){
	$sql = "SELECT * FROM model WHERE ID = '$_POST[model_id]'";
	$result_model = mysql_query($sql,$con);
	$row_model = mysql_fetch_array($result_model);
	
	$commentNum = $row_model['commentNum']+1;
	
	$sql = "UPDATE model SET commentNum = '$commentNum' WHERE ID = '$_POST[model_id]'";
	mysql_query($sql,$con);
	
	$rankResult = $commentNum + $commentNum/100000;
	
	$nowTime = date("Y-m-d H:i:s");
	$sql = "INSERT INTO discuss (MODEL_ID,USER_ID,content,createTime,rankResult) 
						VALUES ('$_POST[model_id]',
								'$_SESSION[user_id]',		
								'$_POST[model_content]',
								'$nowTime',
								'$rankResult'
								)";
	mysql_query($sql,$con);
	}else{
		echo "请登录！";
		}
	
	
	
	mysql_close($con);
?>

